// SPDX-License-Identifier: LGPL-2.1-only
/*
 * Author: Weijie Gao <hackpascal@gmail.com>
 *
 * Etron SPI-NAND flash parts
 */

#include <stdio.h>
#include <string.h>
#include <ufprog/sizes.h>
#include "core.h"
#include "ecc.h"
#include "otp.h"

/* Etron vendor flags */
#define ETRON_F_PP_OTP_PAGE_0				BIT(0)

static const struct spi_nand_part_flag_enum_info etron_vendor_flag_info[] = {
	{ 0, "param-page-otp-page-0" },
};

static struct nand_otp_info etron_4_otp = {
	.start_index = 0,
	.count = 4,
};

static struct nand_otp_info etron_otp = {
	.start_index = 1,
	.count = 63,
};

static const struct nand_page_layout etron_2k_64_no_oob_ecc_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(1),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(2),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(2),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(2),
	ECC_PAGE_PARITY_BYTES(14),
);

static const struct nand_page_layout etron_2k_64_ecc_interleaving_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_PARITY_BYTES(8),
);

static const struct nand_page_layout etron_2k_64_ecc_interleaving_2_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_DATA_BYTES(7),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_DATA_BYTES(8),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_DATA_BYTES(8),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_DATA_BYTES(8),
	ECC_PAGE_PARITY_BYTES(8),
);

const struct nand_page_layout etron_2k_64_ecc_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(4),
	ECC_PAGE_PARITY_BYTES(32),
);

static const struct nand_page_layout etron_2k_120_ecc_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
);

static const struct nand_page_layout etron_2k_128_ecc_interleaving_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
);

static const struct nand_page_layout etron_2k_128_ecc_interleaving_2_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_DATA_BYTES(23),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_DATA_BYTES(24),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_DATA_BYTES(24),
	ECC_PAGE_PARITY_BYTES(8),
	ECC_PAGE_OOB_DATA_BYTES(24),
	ECC_PAGE_PARITY_BYTES(8),
);

const struct nand_page_layout etron_2k_128_ecc_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(2048),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(56),
);

static const struct nand_page_layout etron_4k_240_ecc_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(4096),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(12),
	ECC_PAGE_PARITY_BYTES(14),
);

const struct nand_page_layout etron_4k_256_ecc_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(4096),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(112),
);

static const struct nand_page_layout etron_4k_256_ecc_interleaving_layout = ECC_PAGE_LAYOUT(
	ECC_PAGE_DATA_BYTES(4096),
	ECC_PAGE_MARKER_BYTES(1),
	ECC_PAGE_OOB_FREE_BYTES(3),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
	ECC_PAGE_OOB_FREE_BYTES(4),
	ECC_PAGE_OOB_DATA_BYTES(14),
	ECC_PAGE_PARITY_BYTES(14),
);

static const struct nand_memorg snand_memorg_em73c044sna = SNAND_MEMORG(2048, 64, 128, 512, 1, 1);

static DEFINE_SNAND_ALIAS(em73c044sna_alias, SNAND_ALIAS_MODEL("EM73C044BDA"), SNAND_ALIAS_MODEL("EM73C044BWA"));
static DEFINE_SNAND_ALIAS(em73c044snb_alias, SNAND_ALIAS_MODEL("EM73C044BDB"), SNAND_ALIAS_MODEL("EM73C044BWB"));
static DEFINE_SNAND_ALIAS(em73d044sna_alias, SNAND_ALIAS_MODEL("EM73D044BDA"), SNAND_ALIAS_MODEL("EM73D044BWA"));
static DEFINE_SNAND_ALIAS(em73e044sna_alias, SNAND_ALIAS_MODEL("EM73E044BDA"), SNAND_ALIAS_MODEL("EM73E044BWA"));

static const struct spi_nand_flash_part etron_parts[] = {
	SNAND_PART("EM73B044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x01), &snand_memorg_512m_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73E044SNA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x03), &snand_memorg_4g_4k_256,
		   NAND_ECC_REQ(512, 8),
		   SNAND_ALIAS(&em73e044sna_alias),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044SNF", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x09), &snand_memorg_1g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044SNC", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x0a), &snand_memorg_2g_2k_120,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_120_ecc_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73E044SND", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x0b), &snand_memorg_4g_4k_240,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_4k_240_ecc_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044SNG", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x0c), &snand_memorg_1g_2k_120,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_120_ecc_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73E044SNE", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x0e), &snand_memorg_8g_4k_256,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCN", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x0f), &snand_memorg_2g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044SNF", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x10), &snand_memorg_2g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044SNB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x11), &snand_memorg_1g_2k_120,
		   NAND_ECC_REQ(512, 8),
		   SNAND_ALIAS(&em73c044snb_alias),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_120_ecc_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044SNA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x12), &snand_memorg_2g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_ALIAS(&em73d044sna_alias),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x13), &snand_memorg_2g_2k_128,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_interleaving_2_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x14), &snand_memorg_2g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_2_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCD", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x17), &snand_memorg_2g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x18), &snand_memorg_1g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_2_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044SNA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x19), &snand_memorg_em73c044sna,
		   NAND_ECC_REQ(512, 8),
		   SNAND_ALIAS(&em73c044sna_alias),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_no_oob_ecc_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCH", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x1b), &snand_memorg_2g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044VCD", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x1c), &snand_memorg_1g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73C044SND", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x1d), &snand_memorg_1g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044SND", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x1e), &snand_memorg_2g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCG", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x1f), &snand_memorg_2g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(80),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_interleaving_layout),
		   NAND_OTP_INFO(&etron_4_otp),
	),

	SNAND_PART("EM73D044VCE", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x20), &snand_memorg_2g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73C044VCC", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x22), &snand_memorg_1g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73E044SNB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x23), &snand_memorg_4g_4k_256,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73F044SNA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x24), &snand_memorg_8g_4k_256,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73C044VCF", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x25), &snand_memorg_1g_2k_64,
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73E044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x2c), &snand_memorg_4g_4k_256,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73F044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x2d), &snand_memorg_8g_4k_256,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73D044VCL", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x2e), &snand_memorg_2g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73E044VCB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x2f), &snand_memorg_4g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73C044SNC", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x31), &snand_memorg_1g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM73D044SNB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x32), &snand_memorg_2g_2k_128,
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(120),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78D044VCF", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x81), &snand_memorg_2g_2k_64, /* 1.8V */
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78C044VCF", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x85), &snand_memorg_1g_2k_64, /* 1.8V */
		   NAND_ECC_REQ(512, 4),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_2k_64_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78E044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x8c), &snand_memorg_4g_4k_256, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78F044VCA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x8d), &snand_memorg_8g_4k_256, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78D044VCM", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x8e), &snand_memorg_2g_2k_128, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78E044VCD", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0x8f), &snand_memorg_4g_2k_128, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78E044SNB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0xa3), &snand_memorg_4g_4k_256, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78F044SNA", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0xa4), &snand_memorg_8g_4k_256, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_4k_256_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78C044SNC", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0xb1), &snand_memorg_1g_2k_128, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),

	SNAND_PART("EM78D044SNB", SNAND_ID(SNAND_ID_DUMMY, 0xd5, 0xb2), &snand_memorg_2g_2k_128, /* 1.8V */
		   NAND_ECC_REQ(512, 8),
		   SNAND_FLAGS(SNAND_F_NO_PP),
		   SNAND_VENDOR_FLAGS(ETRON_F_PP_OTP_PAGE_0),
		   SNAND_QE_CR_BIT0, SNAND_ECC_CR_BIT4, SNAND_OTP_CR_BIT6,
		   SNAND_RD_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4),
		   SNAND_PL_IO_CAPS(BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4),
		   SNAND_RD_OPCODES(default_rd_opcodes_q2d),
		   SNAND_SPI_MAX_SPEED_MHZ(100),
		   SNAND_PAGE_LAYOUT(&etron_2k_128_ecc_layout),
		   NAND_OTP_INFO(&etron_otp),
	),
};

static ufprog_status etron_part_fixup(struct spi_nand *snand, struct spi_nand_flash_part_blank *bp)
{
	spi_nand_blank_part_fill_default_opcodes(bp);

	bp->p.nops = bp->p.memorg->page_size / 512;

	if (bp->p.vendor_flags & ETRON_F_PP_OTP_PAGE_0)
		spi_nand_probe_onfi_generic(snand, bp, 0, false);

	return UFP_OK;
}

static const struct spi_nand_flash_part_fixup etron_fixups = {
	.pre_param_setup = etron_part_fixup,
};

static const struct spi_nand_flash_part_ops etron_part_ops = {
	.check_ecc = spi_nand_check_ecc_8bits_sr_2bits,
};

static ufprog_status etron_pp_post_init(struct spi_nand *snand, struct spi_nand_flash_part_blank *bp)
{
	bp->p.qe_type = QE_CR_BIT0;
	bp->p.ecc_type = ECC_CR_BIT4;
	bp->p.otp_en_type = OTP_CR_BIT6;

	bp->p.rd_io_caps = BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_X2 | BIT_SPI_MEM_IO_X4;
	bp->p.pl_io_caps = BIT_SPI_MEM_IO_1_1_1 | BIT_SPI_MEM_IO_1_1_4;

	return UFP_OK;
}

static const struct spi_nand_vendor_ops etron_ops = {
	.pp_post_init = etron_pp_post_init,
};

const struct spi_nand_vendor vendor_etron = {
	.mfr_id = SNAND_VENDOR_ETRON,
	.id = "etron",
	.name = "Etron",
	.parts = etron_parts,
	.nparts = ARRAY_SIZE(etron_parts),
	.ops = &etron_ops,
	.default_part_ops = &etron_part_ops,
	.default_part_fixups = &etron_fixups,
	.default_part_otp_ops = &spi_nand_otp_ops,
	.vendor_flag_names = etron_vendor_flag_info,
	.num_vendor_flag_names = ARRAY_SIZE(etron_vendor_flag_info),
};
